| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | class EANencoder{ |
||
| 2 | constructor(){ |
||
| 3 | // Standard start end and middle bits |
||
| 4 | this.startBin = "101"; |
||
| 5 | this.endBin = "101"; |
||
| 6 | this.middleBin = "01010"; |
||
| 7 | |||
| 8 | this.binaries = { |
||
| 9 | // The L (left) type of encoding |
||
| 10 | "L": [ |
||
| 11 | "0001101", |
||
| 12 | "0011001", |
||
| 13 | "0010011", |
||
| 14 | "0111101", |
||
| 15 | "0100011", |
||
| 16 | "0110001", |
||
| 17 | "0101111", |
||
| 18 | "0111011", |
||
| 19 | "0110111", |
||
| 20 | "0001011" |
||
| 21 | ], |
||
| 22 | |||
| 23 | // The G type of encoding |
||
| 24 | "G": [ |
||
| 25 | "0100111", |
||
| 26 | "0110011", |
||
| 27 | "0011011", |
||
| 28 | "0100001", |
||
| 29 | "0011101", |
||
| 30 | "0111001", |
||
| 31 | "0000101", |
||
| 32 | "0010001", |
||
| 33 | "0001001", |
||
| 34 | "0010111" |
||
| 35 | ], |
||
| 36 | |||
| 37 | // The R (right) type of encoding |
||
| 38 | "R": [ |
||
| 39 | "1110010", |
||
| 40 | "1100110", |
||
| 41 | "1101100", |
||
| 42 | "1000010", |
||
| 43 | "1011100", |
||
| 44 | "1001110", |
||
| 45 | "1010000", |
||
| 46 | "1000100", |
||
| 47 | "1001000", |
||
| 48 | "1110100" |
||
| 49 | ], |
||
| 50 | |||
| 51 | // The O (odd) encoding for UPC-E |
||
| 52 | "O": [ |
||
| 53 | "0001101", |
||
| 54 | "0011001", |
||
| 55 | "0010011", |
||
| 56 | "0111101", |
||
| 57 | "0100011", |
||
| 58 | "0110001", |
||
| 59 | "0101111", |
||
| 60 | "0111011", |
||
| 61 | "0110111", |
||
| 62 | "0001011" |
||
| 63 | ], |
||
| 64 | |||
| 65 | // The E (even) encoding for UPC-E |
||
| 66 | "E": [ |
||
| 67 | "0100111", |
||
| 68 | "0110011", |
||
| 69 | "0011011", |
||
| 70 | "0100001", |
||
| 71 | "0011101", |
||
| 72 | "0111001", |
||
| 73 | "0000101", |
||
| 74 | "0010001", |
||
| 75 | "0001001", |
||
| 76 | "0010111" |
||
| 77 | ] |
||
| 78 | }; |
||
| 79 | } |
||
| 80 | |||
| 107 |